var t = require("../../../../@babel/runtime/helpers/defineProperty"), a = require("../../../../@babel/runtime/helpers/typeof"), e = getApp();

Page({
    data: {
        language: "",
        active: 0,
        rewardsData: {},
        recordsList: [],
        MemberData: {},
        url: "",
        amount_id: "",
        currentTabIndex: 1,
        isLoadMore: !0,
        page: 1,
        total_page: 0
    },
    onLoad: function(t) {
        this.checkrouter(), this.initData(), this.getIndex(), this.getMember(), this.handleClick(0);
    },
    checkrouter: function() {
        try {
            var t = function() {
                for (var t = wx.getStorageSync("yz_basic_info"), a = t.popularize_page.mini.vue_route, e = 0; e < a.length; e++) if ("ClockPunch" == a[e]) return console.log(t.popularize_page.mini.mini_url + "跳转的路径"), 
                wx.showToast({
                    title: "未开启推广权限",
                    duration: 1e3,
                    icon: "none",
                    success: function() {
                        setTimeout(function() {
                            wx.redirectTo({
                                url: t.popularize_page.mini.mini_url
                            });
                        }, 1e3);
                    }
                }), {
                    v: void 0
                };
            }();
            if ("object" === a(t)) return t.v;
        } catch (t) {
            console.log(t);
        }
    },
    onReady: function() {
        var t = wx.getStorageSync("langIndex");
        this.setData({
            language: t.en
        });
    },
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {
        this.data.isLoadMore ? this.getMoreData() : console.log("没有更多数据");
    },
    onShareAppMessage: function() {},
    initData: function() {
        this.setData({
            rewardsData: {},
            recordsList: [],
            active: 0,
            page: 1,
            currentTabIndex: 1,
            total_page: 0,
            amount_id: "",
            isLoadMore: !0
        });
    },
    getIndex: function() {
        var t = this, a = e.getNetAddresss("plugin.diy-queue.frontend.diy-queue.get-statistics");
        e._getNetWork({
            url: a,
            data: {},
            success: function(a) {
                var e = a.data;
                1 == e.result ? t.setData({
                    rewardsData: e.data
                }) : wx.showToast({
                    icon: "none",
                    title: e.msg,
                    duration: 1500
                });
            },
            fail: function(t) {
                console.log(t);
            }
        });
    },
    getMember: function() {
        var t = this, a = e.getNetAddresss("plugin.diy-queue.frontend.diy-queue.get-member");
        e._getNetWork({
            url: a,
            data: {},
            success: function(a) {
                var e = a.data;
                1 == e.result ? t.setData({
                    MemberData: e.data.member
                }) : wx.showToast({
                    icon: "none",
                    title: e.msg,
                    duration: 1500
                });
            },
            fail: function(t) {
                console.log(t);
            }
        });
    },
    handleClickbtn: function(t) {
        var a = t.detail.index;
        this.handleClick(a);
    },
    handleClick: function(t, a) {
        this.setData({
            amount_id: "",
            recordsList: []
        }), this.data.currentTabIndex !== t && (this.setData({
            currentTabIndex: t
        }), 1 === t ? this.setData({
            url: "plugin.diy-queue.frontend.diy-queue.get-logs"
        }) : this.setData({
            url: "plugin.diy-queue.frontend.diy-queue.get-queues"
        }), this.getData());
    },
    getData: function() {
        this.setData({
            isLoadMore: !1,
            page: 1
        });
        var t = this, a = e.getNetAddresss(this.data.url);
        e._getNetWork({
            url: a,
            data: {
                page: 1
            },
            success: function(a) {
                var e = a.data;
                1 == e.result ? (t.setData({
                    isLoadMore: !0
                }), 1 === t.data.currentTabIndex ? t.setData({
                    total_page: e.data.logs.last_page,
                    recordsList: e.data.logs.data
                }) : t.setData({
                    total_page: e.data.queues.last_pag,
                    recordsList: e.data.queues.data
                }), t.data.total_page || t.setData({
                    total_page: 0
                })) : wx.showToast({
                    icon: "none",
                    title: e.msg,
                    duration: 1500
                });
            },
            fail: function(t) {
                console.log(t);
            }
        });
    },
    getMoreData: function() {
        var t = this;
        if (this.setData({
            isLoadMore: !1
        }), !(this.data.page >= this.data.total_page)) {
            this.setData({
                page: this.data.page + 1
            });
            var a = e.getNetAddresss(this.data.url);
            e._getNetWork({
                url: a,
                data: {
                    page: this.data.page
                },
                success: function(a) {
                    var e = a.data;
                    1 == e.result ? (1 === t.data.currentTabIndex ? myData = e.data.logs.data : myData = e.data.queues.data, 
                    t.setData({
                        recordsList: t.data.recordsList.concat(myData)
                    })) : t.setData({
                        page: t.data.page - 1,
                        isLoadMore: !1
                    });
                },
                fail: function(t) {
                    console.log(t);
                }
            });
        }
    },
    showMore: function(a) {
        var e = a.currentTarget.dataset.index, s = a.currentTarget.dataset.item;
        s.show && this.data.amount_id === s.id ? this.setData(t({}, "recordsList[" + e + "].show", !1)) : this.setData(t({
            amount_id: s.id
        }, "recordsList[" + e + "].show", !0));
    }
});